<?php

namespace app\common\validate;

use think\Validate;

class RolesValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...].
     *
     * @var array
     */
    protected $rule = [
        'id|编号' => 'require|number|gt:0',
        'apis_list|授权接口列表' => 'require',
        'parent_id|父角色id' => 'require|number|egt:0',
        'name|角色名称' => 'require|chs|min:2',
        'describe|描述' => 'require',
        'page|页数' => 'require|number|gt:0',
        'limit|分页大小' => 'require|number|gt:5',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'.
     *
     * @var array
     */
    protected $message = [];
    protected $scene = [
        'getList' => ['page', 'limit'],
        'saveAdd' => ['parent_id', 'name', 'describe'],
        'saveEdit' => ['id'],
        'getRow' => ['id'],
        'savePower' => ['id', 'apis_list'],
    ];
}
